//
//  SinaTabBarViewController.m
//  oc微博
//
//  Created by 安陆与 on 16/1/14.
//  Copyright © 2016年 安陆与. All rights reserved.
//

#import "SinaTabBarViewController.h"
#import "SinaTabBar.h"
#import "SinaFindViewController.h"
#import "SinaHomeViewController.h"
#import "SinaMessageViewController.h"
#import "SinaSettingViewController.h"

@interface SinaTabBarViewController ()

@end

@implementation SinaTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor redColor];
    
    [self addVC];
    
    SinaTabBar *tabBar = [[SinaTabBar alloc]init];
    
    tabBar.backgroundColor = [UIColor greenColor];
    [self setValue:tabBar forKeyPath:@"tabBar"];

}


-(void)addVC{

    SinaFindViewController *find = [[SinaFindViewController alloc]init];
    SinaHomeViewController *home = [[SinaHomeViewController alloc]init];

    SinaMessageViewController *message = [[SinaMessageViewController alloc]init];

    SinaMessageViewController *setting = [[SinaMessageViewController alloc]init];

    
    [self addChildViewController:home title:@"首页" image:@"tabbar_home"];
    [self addChildViewController:message title:@"消息" image:@"tabbar_message_center"];

    [self addChildViewController:find title:@"发现" image:@"tabbar_discover"];

    [self addChildViewController:setting title:@"设置" image:@"tabbar_profile"];

}


-(void)addChildViewController:(UIViewController *)childController title:(NSString *)title image:(NSString *)image{

    [childController setTitle:title];
    
    childController.tabBarItem.image = [[UIImage imageNamed:image]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    NSString *str = [NSString stringWithFormat:@"%@_highlighted",image];
    
    childController.tabBarItem.selectedImage = [UIImage imageNamed:str];
    
    UINavigationController *vc = [[UINavigationController alloc]initWithRootViewController:childController];
    
    [self addChildViewController:vc];
}




@end
